window.onload=function  () {
	var column=document.getElementsByClassName('column');
	var click=document.getElementsByClassName('click');
	var left = document.getElementById('left');
	var right = document.getElementById('right');
	var num=0;
	var cnt = 0;

	var imgbackground = ['#B6C64E','#C2F3FE','#F9F8FC','#FFFFFF','#262729','#EAE9EB'];
	// 定义背景颜色
	var run=function  () {
		cnt =0;
		for (var i = 0;i<column.length;  i++) {
			column[i].style.display='none';
			click[i].style.backgroundColor='';
		};
		column[num].style.display='block';
		click[num].style.backgroundColor='#00C3F5';
		column[0].parentNode.parentNode.style.backgroundColor=imgbackground[num];
		num++;
		if (num==column.length) {
			num=0;
		};
		// alert(num);
	}
	var sun=function  () {
		if (num==-1) {
			num=0;
		}
		if (num==0) {
			num=column.length-1;
		}
		if (num==-2) {
			num=column.length-1;
		}
		if (num==0) {
			num=column.length-1;
		}
		if(cnt==0){
			num -=2;
			cnt =1;
		}

		for (var i = 0;i<column.length;  i++) {
			column[i].style.display='none';
			click[i].style.backgroundColor='';
		};
		column[num].style.display='block';
		click[num].style.backgroundColor='#00C3F5';
		column[0].parentNode.parentNode.style.backgroundColor=imgbackground[num];
		num--;

		if (num==-1) {
			num=column.length-1;
		};

		
	}
	run();
	var time=setInterval(run,1000);
	// 执行计时器

	var father = document.getElementById('main');

	father.onmouseover = function  () {
		clearInterval(time);
		left.style.backgroundColor='#858585';
		right.style.backgroundColor='#858585';

		// 鼠标进入main标签里面后清除计时器
	}
	father.onmouseout=function  () {
		time=setInterval(run,1000);
		left.style='none';
		right.style='none';
		// 鼠标离开main标签后重新开始计时器
	}

	for (var i = 0; i < click.length; i++) {
		dian(i);
	};

	function dian (i) {
		click[i].onclick =function() {
			num=i;
			run();
		}
	}
	

	left.onclick = function  (argument) {
		sun();
	}

	right.onclick = function  (argument) {
		// alert(num);
		run();
	}

}

